package com.orifine.orm.type;

import com.orifine.orm.Information;
import com.orifine.orm.Type;
import com.orifine.orm.information.NumberRandomInfo;
import com.orifine.orm.model.ColumnModel;

public class Int extends Type{
	public Integer number;
	
	public Int(){
		
	}
	
	public Int(Integer number){
		this.number = number;
	}

	@Override
	public String getScriptType(ColumnModel columnMapper){
		String lengthString = "";
		String typeString = "INT";
		if(columnMapper.getLength().getValue() != 0){
			lengthString = "("+columnMapper.getLength().getValue()+")";
		}
		return typeString + lengthString;
	}

	public String toString(){
		return number.toString();
	}
	
	public Integer valueInteger(){
		return number;
	}

	@Override
	public String getScriptValue(ColumnModel columnMapper){
		if(number == null){
			return "NULL";
		} else {
			return number.toString();
		}
	}

	@Override
	public Information getDefaultInfo(ColumnModel columnMapper){
		return new NumberRandomInfo(20000);
	}
}
